package com.core.zyyz.amc.modules.controller;

import com.core.common.core.controller.BaseController;
import com.core.common.core.page.TableDataInfo;
import com.core.common.utils.StringUtils;
import com.core.zyyz.amc.modules.domain.TableColumn;
import com.core.zyyz.amc.modules.service.AmcCodeManageService;
import com.core.zyyz.amc.modules.service.AmcSystemFunctionBService;
import io.netty.util.internal.StringUtil;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("amc/sysFunctionB")
public class AmcSystemFunctionBController extends BaseController {

    @Autowired
    private AmcSystemFunctionBService amcSystemFunctionBService;
    /**
     * 查询库中所有表
     * @param param
     * @return
     */
    @GetMapping("/query/tableList")
    public TableDataInfo queryTableList(@RequestParam Map<String, Object> param){
        String tableComment = MapUtils.getString(param,"tableComment");
        if(StringUtils.isNotEmpty(tableComment)){
            param.put("tableComment","%"+tableComment+"%");
        }
        List<TableColumn> list = amcSystemFunctionBService.queryTableList(param);
        return getDataTable(list);
    }

    /**
     * 查询库中所有列
     * @param param
     * @return
     */
    @GetMapping("/query/columnList")
    public TableDataInfo queryColumnList(@RequestParam Map<String, Object> param){
        String tabName = MapUtils.getString(param,"tableName");
        if(StringUtil.isNullOrEmpty(tabName)){
            return getDataTable(new ArrayList<>());
        }
        startPage();
        List<TableColumn> list = amcSystemFunctionBService.queryColumnList(param);

        return getDataTable(list);
    }
}
